package com.rongji.dfish.ui.annotation;

import java.lang.annotation.Annotation;

public class Data4Ui implements Data4FlexGrid, Data4FormPanel{

	private Data4FlexGrid data4FlexGrid;
	private Data4FormPanel data4FormPanel;
	public Data4Ui () {
		this.data4FlexGrid = null;
		this.data4FormPanel = null;		
	}
	public Data4Ui (Data4FlexGrid data4FlexGrid) {
		this.data4FlexGrid = data4FlexGrid;
		this.data4FormPanel = null;		
	}
	public Data4Ui (Data4FormPanel data4FormPanel) {
		this.data4FlexGrid = null;
		this.data4FormPanel = data4FormPanel;		
	}
	public Data4FlexGrid getData4FlexGrid() {
		return data4FlexGrid;
	}

	public void setData4FlexGrid(Data4FlexGrid data4FlexGrid) {
		this.data4FlexGrid = data4FlexGrid;
		this.data4FormPanel = null;
	}

	public Data4FormPanel getData4FormPanel() {
		return data4FormPanel;
	}

	public void setData4FormPanel(Data4FormPanel data4FormPanel) {
		this.data4FormPanel = data4FormPanel;
		this.data4FlexGrid = null;
	}

	@Override
	public Class<? extends Annotation> annotationType() {
		if (data4FlexGrid != null) {
			return data4FlexGrid.annotationType();
		} else if (data4FormPanel != null) {
			return data4FormPanel.annotationType();
		}
		return null;
	}

	@Override
	public int fromRow() {
		if(data4FormPanel != null) {
			return data4FormPanel.fromRow();
		}
		return -1;
	}

	@Override
	public int fromColumn() {
		if(data4FormPanel != null) {
			return data4FormPanel.fromColumn();
		}
		return -1;
	}

	@Override
	public int toRow() {
		if(data4FormPanel != null) {
			return data4FormPanel.toRow();
		}
		return -1;
	}

	@Override
	public int toColumn() {
		if(data4FormPanel != null) {
			return data4FormPanel.toColumn();
		}
		return -1;
	}
	
	@Override
	public String name() {
		if(data4FormPanel != null) {
			return data4FormPanel.name();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.name();
		}
		return null;
	}

	@Override
	public NodeType type() {
		if(data4FormPanel != null) {
			return data4FormPanel.type();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.type();
		}
		return null;
	}

	@Override
	public String label() {
		if(data4FormPanel != null) {
			return data4FormPanel.label();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.label();
		}
		return "";
	}

	@Override
	public int order() {
		if(data4FormPanel != null) {
			return data4FormPanel.order();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.order();
		}
		return -1;
	}

	@Override
	public String format() {
		if(data4FormPanel != null) {
			return data4FormPanel.format();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.format();
		}
		return "yyyy-mm-dd";
	}

	@Override
	public boolean required() {
		if(data4FormPanel != null) {
			return data4FormPanel.required();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.required();
		}
		return false;
	}

	@Override
	public String src() {
		if(data4FormPanel != null) {
			return data4FormPanel.src();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.src();
		}
		return "";
	}

	@Override
	public int occupy() {
		if (data4FlexGrid != null) {
			return data4FlexGrid.occupy();
		}
		return 1;
	}
	
	public boolean isEmpty() {
		if (data4FlexGrid == null && data4FormPanel == null) {
			return true;
		}
		return false;
	}
	@Override
	public String dropSrc() {
		if(data4FormPanel != null) {
			return data4FormPanel.dropSrc();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.dropSrc();
		}
		return "";
	}
	@Override
	public double minValue() {
		if(data4FormPanel != null) {
			return data4FormPanel.minValue();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.minValue();
		}
		return Double.MIN_VALUE;
	}
	@Override
	public double maxValue() {
		if(data4FormPanel != null) {
			return data4FormPanel.maxValue();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.maxValue();
		}
		return Double.MAX_VALUE;
	}
	@Override
	public double step() {
		if(data4FormPanel != null) {
			return data4FormPanel.step();
		} else if (data4FlexGrid != null) {
			return data4FlexGrid.step();
		}
		return 1;
	}
}
